package com.example.task1.ui.AllService.traffic;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.bean.TrafficPenaltyBean;
import com.example.task1.bean.TrafficUndoListBean;
import com.example.task1.http.Api;
import com.example.task1.ui.BaseAdapter;
import com.example.task1.util.ApiResp;
import com.example.task1.util.CallBack;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;

import retrofit2.Call;

public class TrafficPenaltyListAdapter extends BaseAdapter<TrafficPenaltyBean.RowsDTO> {

    private Context context;
    private List<TrafficPenaltyBean.RowsDTO> mData = new ArrayList<>();
    private TextView tvTrafficOffence;
    private TextView tvStatus;
    private TextView tvLicencePlate;
    private TextView tvIllegalSites;
    private TextView tvCatType;
    private TextView tvPerformDate;
    private Button btnUndo;
    private Button btnAcceptance;

    public TrafficPenaltyListAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<TrafficPenaltyBean.RowsDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.trafficundolist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<TrafficPenaltyBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, TrafficPenaltyBean.RowsDTO date) {

    }

    @Override
    protected void onBind(myHolder holder, TrafficPenaltyBean.RowsDTO date, int position) {
        tvTrafficOffence.setText(date.getIllegalEven());
        tvStatus.setText("扣"+date.getDeductMarks()+"分");
        tvLicencePlate.setText("车牌：" + date.getPlateNo());
        tvCatType.setText("号牌种类：" + date.getCarType());
        tvIllegalSites.setText("违章地点" + date.getIllegalAddress());
        tvPerformDate.setText("处罚日期：" + date.getPerformDate());
        btnAcceptance.setVisibility(View.GONE);
        btnUndo.setVisibility(View.GONE);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getItemViewType(int position) {
        return position;
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View view) {
        tvTrafficOffence = (TextView) view.findViewById(R.id.tv_trafficOffence);
        tvStatus = (TextView) view.findViewById(R.id.tv_status);
        tvLicencePlate = (TextView) view.findViewById(R.id.tv_licencePlate);
        tvIllegalSites = (TextView) view.findViewById(R.id.tv_illegalSites);
        tvCatType = (TextView) view.findViewById(R.id.tv_catType);
        tvPerformDate = (TextView) view.findViewById(R.id.tv_performDate);
        btnUndo = (Button) view.findViewById(R.id.btn_undo);
        btnAcceptance = (Button) view.findViewById(R.id.btn_acceptance);
    }
}
